<link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet">
<link href="{{ asset('css/font-awesome.min.css') }}" rel="stylesheet" />
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<script src="{{ asset('js/jquery-1.8.3.min.js') }}" type="text/javascript"></script>
<link rel="stylesheet" href="{{URL::asset('./css/login.css')}}">
<link rel="stylesheet" href="{{URL::asset('./css/reset.css')}}">
<!-- <a><img src="{{URL::asset('./img/index/floor_tel.png')}}" alt=""><span> -->
<meta name="_token" content="{{csrf_token()}}">
<style type="text/css">
  [v-cloak] {
    display: none !important;
  }

  .login_title {
    margin-top: 80px;
  }

  .loginMain .el-input--mini .el-input__inner {
    height: 40px;
    line-height: 40px;
    font-size: 16px;
  }

  .el-input--mini {
    margin-top: 20px;
  }

  .submit {
    margin-top: 65px;
  }

  .tit_text {
    margin-top: 25px;
    line-height: 30px;
  }
</style>
<div id="login">
  <div class="login_header">
    <div class="login_headerDiv">
      <a href="{{route('home.index.index') }}">
        <img :src="overall.site_logo">
      </a>
      <div class="login_headerTel">
        <span class="login_headerTel_tel">@{{overall.customer_mobile}}</span>
        <span class="login_headerTel_time">
          服务时间：周一至周五9:00 - 18:00
        </span>
      </div>
    </div>
  </div>
  <div class="loginBg">
    <div class="loginForm">
      <div class="loginMain" style="width:300px">

        <div class="login_title">
          <img :src="overall.site_logo">
        </div>
        <el-form :model="form" label-position="top" size="mini" ref="form">
          <el-form-item prop="tel" :rules="telRule">
            <el-input v-model="form.tel" placeholder="手机号"></el-input>
          </el-form-item>
          <el-form-item prop="password" :rules="passRule">
            <el-input v-model="form.password" placeholder="密码" show-password></el-input>
          </el-form-item>
        </el-form>
        <el-button class="submit" type="primary" :loading="submitBo" @click="submitForm('form')">
          绑定
        </el-button>
        <p class="tit_text">提示： 绑定已有的启点网帐号后，即可以在登录页面使用第三方登录方式登录此启点网帐号。</p>
      </div>
    </div>
  </div>
  <div class="login_footer">
  <div class="login_footer_first">
            <a href="{{route('home.index.index') }}">
                首页 
            </a>
            <span>|</span>
            <a href="{{route('home.store.storeList') }}">
                供应商
            </a>
            <span>|</span>
            <a href="{{route('home.activity.actCate') }}">
                活动/会议/培训
            </a>
            <span>|</span>
            <a href="{{route('home.goods.goodsCate') }}">
                商品
            </a>
            <span>|</span>
            <a href="{{route('home.word.wordCate') }}">
                文档下载
            </a>
            <span>|</span>
            <a href="{{route('home.demand.demandList') }}">
                需求市场
            </a>
            <span>|</span>
            <a href="{{route('home.news.news') }}">
                新闻资讯
            </a>
        </div>
    <div class="login_footer_two">
      <a>
        <img src="{{URL::asset('./img/1.png')}}">
      </a>
      <a>
        <img src="{{URL::asset('./img/2.png')}}">
      </a>
      <!-- <a>
        <img src="{{URL::asset('./img/3.png')}}">
      </a> -->
      <a>
        <img src="{{URL::asset('./img/4.png')}}">
      </a>
      <a>
        <img src="{{URL::asset('./img/5.png')}}">
      </a>
      <!-- <a>
        <img src="{{URL::asset('./img/6.png')}}">
      </a> -->
    </div>
    <div class="login_footer_three">
      <a>Copyright 2019-2022 www.hrqidian.com 重庆启群大数据科技有限公司版权所有 备案：渝ICP备19010042号-1</a>
    </div>
  </div>
</div>

<script src="{{ asset('js/vue.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/element.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/moment.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/bootstrap.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/public.js') }}" type="text/javascript"></script>

<script>
  $(() => {
    var validateTel = (rule, value, callback) => {
      var reg = /^((13|14|15|16|17|18|19)[0-9]\d{8})$/;
      if (value == '') {
        callback(new Error('请输入联系电话'));
      } else if (!reg.test(value)) {
        callback(new Error('请输入正确的联系电话!'));
      } else {
        callback();
      }
    };
    let app = new Vue({
      el: '#login',
      data: () => {

        return {
          overall: "",
          form: {
            tel: "",
            password: '',
            code: ''
          },
          type : "{{ $three['type'] }}",
          three_id : "{{ $three['idstr'] }}",
          telRule: [{
            required: true,
            validator: validateTel,
            trigger: 'blur'
          }],
          passRule: [{
            required: true,
            message: '密码不能为空',
            trigger: 'blur'
          }],
          remenberBo: false,
          codeTime: 60,
          submitBo: false,
          codeBo: false
        }
      },
      created() {
        this.keyupSubmit()
        window.$message = (res) => {
          this.$message({
            message: res,
            type: 'error'
          });
        }
        $.get("{{ route('home.public.config') }}", (res) => {
          sessionStorage.setItem("overall", JSON.stringify(res.data))
          this.overall = res.data
        });
        this.form.tel = getCookie("HRTel") || '';
        this.form.password = getCookie("HRPassword") || '';
        if (getCookie("HRTel")) {
          this.remenberBo = true;
        }
      },
      methods: {
        keyupSubmit() {
          document.onkeydown = e => {
            let _key = window.event.keyCode;
            if (_key === 13) {
              this.submitForm('form')
            }
          }
        },
        submitForm(formName) {
          this.$refs[formName].validate((valid) => {
            if (valid) {
              this.submitBo = true;
              //账号密码登录
              let data = {
                mobile: this.form.tel,
                password: this.form.password,
                type: this.type,
                three_id: this.three_id,
                user_type: 1
              }
              apiAjax("{{ route('home.login.login') }}", 'post', data, (res) => {
                if (res.code == 0) {
                  this.$message({
                    message: '登录成功',
                    type: 'success'
                  });
                  if (this.remenberBo) {
                    setCookie('HRTel', this.form.tel);
                    setCookie('HRPassword', this.form.password);
                  } else {
                    delCookie('HRTel')
                    delCookie('HRPassword')
                  }
                  sessionStorage.setItem("HRuserDetails", JSON.stringify(res.data))
                  window.location.href = "{{ route('home.index.index') }}";
                } else {
                  this.$message({
                    message: res.msg,
                    type: 'warning'
                  });
                }
                this.submitBo = false;
              }, (erro) => {
                this.submitBo = false;
              });
            } else {
              console.log('error submit!!');
              return false;
            }
          });
        },
      }

    })
  })
</script>